
<script setup>
import { useScroll } from '@vueuse/core'
const {y} = useScroll(window)
function scrollToElement(id, offset) {
  const el = document.getElementById(id);
  const offsetTop = el.offsetTop - offset;
  window.scrollTo({
    top: offsetTop,
    behavior: 'smooth'
  });
}
</script>
<template>
  <div>
    
    <ul class="vertical-links" :class="{show:y>200}">
      <li><a @click="scrollToElement('banner', 60)">回到顶部</a></li>
      <li><a @click="scrollToElement('rmdcour', 80)">推荐课程</a></li>    
      <li><a @click="scrollToElement('teacher', 80)">教师团队</a></li>
    
    </ul>
  </div>
</template>

<style scoped>
.vertical-links {
  margin: 0;
  padding: 0;
  list-style-type: none;
  position: fixed;
  left: 20px;
  top: 52%;
  background-color: #fff;
  border-radius: 5px;
  transform: translateY(-50%);
  z-index: 100;
  opacity: 0;
 
}
.show {
    transition: all 0.3s linear;
    transform: none;
    opacity: 1;
}
.vertical-links li {
  margin: 0;
  padding: 5px 10px;
  border-bottom: 1px solid #eee;
  text-align: center;
}

.vertical-links li:last-child {
  border-bottom: none;
}

.vertical-links li a {
  display: block;
  padding: 5px;
  color: #333;
  text-decoration: none;
  transition: background-color 0.2s;
  cursor: pointer;
}

.vertical-links li a:hover {
  color:rgb(234, 103, 103);
}
</style>